package com.student.foodAfter.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * ClassName: RedisUtils <br/>
 * Description: <br/>
 * date: 2023/1/15 18:38<br/>
 * @author 李林雨 <br/>
 * @since JDK 8
 */
@Component
public class RedisUtils {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    public void set(String key,String value){
        stringRedisTemplate.opsForValue().set(key,value);
    }

    public String get(String key){
        return stringRedisTemplate.opsForValue().get(key);
    }

    public void hset(String key,String field,Object value){
        stringRedisTemplate.opsForHash().put(key,field,value);
    }

    public Object hget(String key,String field){
        return  stringRedisTemplate.opsForHash().get(key,field);
    }

}
